<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>设备管理</title>
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<link href="css/mui.picker.min.css" rel="stylesheet" type="text/css">
		<link href="bootstrap-select/bootstrap-select.css" rel="stylesheet">
		<link href="css/bootstrap.min.css" rel="stylesheet" >
		<script src="js/jquery-1.8.3.min.js"></script>
		 <script charset="UTF-8" src="js/jquery.min.js"></script>
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/echarts.min.js"></script>
		<script charset="UTF-8" src="js/mui.picker.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="bootstrap-select/bootstrap-select.js"></script>
	</head>
	<body>
		<div class="head-zhjf">
			<img src="images/fanhui@3x.png" class="ryjk-tx" onclick="equipmentWearing()">
			<p style="color: white;size: 16px;">添加设备佩戴</p>
		</div>
		<form  id="form1" target="ifr">
		<div class="moban-lb"  >
			<div class="moban-lb-l">
				<div class="ziduan-mb"><span style="color: red;">*</span>设备编号:</div>
			</div>
			<div class="moban-lb-r" style="margin-top: 5px;">
				<select name="cowId" class="selectpicker form-control m-b" data-live-search="true" title="选择编号"  data-size="10" id="noApplicationRecord" required>
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb" >
			<div class="moban-lb-l">
				<div class="ziduan-mb"><span style="color: red;">*</span>耳号:</div>
			</div>
			<div class="moban-lb-r" style="margin-top: 5px;">
				<select name="cowId" class="selectpicker form-control m-b" data-live-search="true" title="选择耳号"  data-size="10" id="deviceStatusID" required>
				</select>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb"><span style="color: red;">*</span>佩戴日期:</div>
			</div>
			<div class="moban-lb-r">
				<input id="syndate" type="text" onclick="dtPicker('syndate')"  onfocus=this.blur()>
			</div>
			<div class="clear"></div>
		</div>
		<div class="moban-lb">
			<div class="moban-lb-l">
				<div class="ziduan-mb">备注:</div>
			</div>
			<div class="moban-lb-r">
				<input id="testText" type="text" placeholder="请输入">
			</div>
			<div class="clear"></div>
		</div>
		
		<div class="tijiao">
			<input type="submit" class="tijiao-btn" value="提交">
		</div>
		</form>
		<iframe name='ifr' id="ifr" style='display: none;'></iframe><!--表单提交防止刷新-->
		<!--封装同步异步请求-->
		<script  charset="UTF-8" src="js/simple.tool.js" ></script>
		<script>
			//获取当前日期
			$("#syndate").val(getDateNow());
			
			var i = setTimeout(function(){
				overbitList = JSON.parse(localStorage.getItem('addCowWearData'));
				console.log(overbitList)
			    if(overbitList != 0){
					var noApplicationRecordArr = overbitList[0].serialList;
					var deviceStatusIDArr = overbitList[0].overbitList;
					loadSelect('noApplicationRecord',noApplicationRecordArr,'cow_id','noApplicationRecord');//设备编号
					$('.selectpicker').selectpicker('refresh');
					loadSelect1('deviceStatusID',deviceStatusIDArr,'cow_id','deviceStatusID');//耳号
					$('.selectpicker').selectpicker('refresh');
				}
			},900);
			
			$("#form1").submit(function () {
			 	var map={};
				map.url="addWearing";
				map.col2=$("#noApplicationRecord").val();
				map.overbit =$("#deviceStatusID").val();
				map.wear_time  =$("#syndate").val();
				map.remake  =$("#testText").val();
				var equipmentID = JSON.parse(localStorage.getItem('equipmentID'));
				if(equipmentID == 1){
					localStorage.setItem('equipmentID', JSON.stringify(0));
					ajaxRequestPostEDS(function (data) {
						equipmentWearing();
					},map)
				}
				 
			});
			
			var noApplicationRecord = document.getElementById('noApplicationRecord');
			var deviceStatusID = document.getElementById('deviceStatusID');
			
			
		
			function loadSelect(id,data,code,name,userName) {
			    $("#"+id).html("");
			    for (i=0;i<data.length;i++){//
					var str='';
					if(userName != null && data[i][name] == userName){
						str='<option value="'+data[i].col2+'" selected>'+data[i].col2+'</option>';
					}else{
						str='<option value="'+data[i].col2+'">'+data[i].col2+'</option>';
					}
			        $("#"+id).append(str);
			    }
			}
			function loadSelect1(id,data,code,name,userName) {
			    $("#"+id).html("");
			    for (i=0;i<data.length;i++){//
					var str='';
					if(userName != null && data[i][name] == userName){
						str='<option value="'+data[i].overbit+'" selected>'+data[i].overbit+'</option>';
					}else{
						str='<option value="'+data[i].overbit+'">'+data[i].overbit+'</option>';
					}
			        $("#"+id).append(str);
			    }
			}
		</script>

	</body>

</html>